home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 25 / AACD 25.iso / AACD / Magazine / Online / QMail / Install < prev    next >
Encoding:
Text File  |  1997-10-05  |  22.6 KB  |  745 lines

  1. ; Installationsscript for qmail
  2. ; Global variables begin with '#'
  3. ; Local variables begin with '_'
  4.  
  5. ; Set up localised strings.
  6. (procedure P_doLocaleStrings
  7.     (if (= @language "dansk")
  8.     (
  9.         (set #askInPlace "Skal der installeres uden kopiering?")
  10.         (set #askInPlaceHelp (cat
  11.              "Det er muligt at installere " @app-name " i den skuffe "
  12.              "installationsfilerne ligger i. Dette betyder at "
  13.              "der ikke skal kopieres filer under installationen."
  14.         ))
  15.         (set #askDestDir (cat
  16.              "Hvor skal " @app-name " installeres?"
  17.         ))
  18.         (set #askDestDirHelp (cat
  19.              "Der vil ikke blive oprettet en ny skuffe til "
  20.              @app-name " i den skuffe du vælger.\n\n"
  21.         ))
  22.         (set #msgDNSsearch "Leder efter DNS servere.")
  23.         (set #msgDNSlookup "Foretager opslag i DNS.")
  24.         (set #msgWritingControls "Skriver kontrolfiler.")
  25.         (set #msgCreatingDirs "Opretter skuffer.")
  26.         (set #msgCreatingUsers "Opretter brugere og grupper.")
  27.         (set #msgMiamiDatabase (cat "Det er nødvendigt at oprette nogle "
  28.             "brugere og grupper for at " @app-name " kan fungere. Dette "
  29.             "kan desværre ikke gøres automatisk i Miami. Du skal derfor "
  30.             "flette ASCII filen \"%s\" ind i Miamis brugerdatabase og flette "
  31.             "ASCII filen \"%s\" i Miamis gruppedatabase (hvordan dette gøres "
  32.             "er beskrevet i brugervejledningen til Miami. Vælg \"Fortsætte\" "
  33.             "når du er færdig med dette."
  34.         ))
  35.         (set #askUserStartup (cat "Skal " @app-name " startes automatisk når "
  36.             "Amiga'en startes op?"
  37.         ))
  38.         (set #askStartNow (cat "Ønsker du at starte " @app-name " nu?"))
  39.     )
  40.     ;else
  41.     (
  42.         (set #askInPlace "Install in-place without copying?")
  43.         (set #askInPlaceHelp (cat
  44.              "It is possible to install " @app-name " in the drawer "
  45.              "containing the installation files. This means "
  46.              "that copying files during installations isn't "
  47.              "necessary."
  48.         ))
  49.         (set #askDestDir (cat
  50.              "Where do you want to install " @app-name "?"
  51.         ))
  52.         (set #askDestDirHelp (cat
  53.              "A new drawer for " @app-name " will not be created"
  54.              "in the drawer you choose.\n\n"
  55.         ))
  56.         (set #msgDNSsearch "Searching for DNS servers.")
  57.         (set #msgDNSlookup "Performing DNS lookups.")
  58.         (set #msgWritingControls "Writing control files.")
  59.         (set #msgCreatingDirs "Creating drawers.")
  60.         (set #msgCreatingUsers "Creating users and groups.")
  61.         (set #msgMiamiDatabase (cat "It is necessary to create some users "
  62.             "and gruops for " @app-name " to work. Unfortunately, it is not "
  63.             "possible to do this automatically with Miami. You will have to "
  64.             "do this by merging the ASCII file \"%s\" with Miami's user "
  65.             "database and merge the ASCII file \"%s\" with Miami's group "
  66.             "database (the Miami user manual describes how to do this). "
  67.             "Choose \"Proceed\" when you have completed this task."
  68.         ))
  69.         (set #askUserStartup (cat "Do you want " @app-name " to be started "
  70.             "automatically when your Amiga boots up?"
  71.         ))
  72.         (set #askStartNow (cat "Do you want to start " @app-name " now?"))
  73.     ))
  74. )    
  75.  
  76. ; Return the position of the character _chr in the string _str,
  77. ; searching from the beginning of the string. Returns the length of _str
  78. ; if _chr is not found.
  79. (procedure P_strchr _str _chr
  80. (
  81.     (set _i 0)
  82.     (set _length (strlen _str))
  83.     (while (AND (< _i _length) (<> (substr _str _i 1) _chr))
  84.         (set _i (+ _i 1))
  85.     )
  86.     _i
  87. ))
  88.  
  89. ; Return the position of the character _chr in the string _str,
  90. ; searching from the end of the string. Returns -1 if _chr is not found.
  91. (procedure P_strrchr _str _chr
  92. (
  93.     (set _i (- (strlen _str) 1))
  94.     (while (AND (=> _i 0) (<> (substr _str _i 1) _chr))
  95.         (set _i (- _i 1))
  96.     )
  97.     _i
  98. ))
  99.  
  100. ; Run an external command and return the output from stdout in #output.
  101. (procedure P_run _command
  102. (
  103.     (set _temp (run (cat _command " >ENV:InstallScriptTemp") (safe)))
  104.     (set #output (getenv "InstallScriptTemp"))
  105.     (delete "ENV:InstallScriptTemp" (safe))
  106.     _temp
  107. ))
  108.  
  109. ; Create an icon of the specified type for the specified file
  110. (procedure P_makeicon _type _file
  111.     (copyfiles
  112.         (source (cat "icons/" _type ".info"))
  113.         (dest (pathonly _file))
  114.         (newname (cat (fileonly _file) ".info"))
  115.         (nogauge)
  116.     )
  117. )
  118.  
  119. ; Try to guess which TCP/IP stack (if any) is used.
  120. (procedure P_guessTCPstack
  121.     (if (= 1 (run "SYS:RexxC/RX \"exit SHOW(PORTS,\'AMITCP\')\"" (safe)))
  122.         "AmiTCP/IP"
  123.  
  124.         (if (= 1 (run "SYS:RexxC/RX \"exit SHOW(PORTS,\'MIAMI.1\')\"" (safe)))
  125.             "Miami"
  126.  
  127.             (if (< 0 (getversion ("socket.library" (resident))))
  128.                 "INET225"
  129.  
  130.                 "None"
  131.             ) ; if
  132.         ) ; if
  133.     ) ; if
  134. ) ; procedure P_guessTCPstack        
  135.  
  136. ; Piece together a host name from environment variables.
  137. (procedure P_gethostnamevars
  138. (
  139.     (set _hostname (getenv "HOSTNAME"))
  140.     (if (NOT _hostname)
  141.         (set _hostname (getenv "HOST"))
  142.     )
  143.     ; Check for a domain part
  144.     (if (NOT (patmatch "#?.#?" _hostname))
  145.         (cat _hostname "." (getenv "DOMAIN"))
  146.     ; else
  147.         _hostname
  148.     )
  149. ))
  150.  
  151. ; Try to find the host name.
  152. (procedure P_gethostname
  153.     (if (= #TCPstack "None")
  154.         (P_gethostnamevars)
  155.     ;else
  156.         (if (= 0 (P_run "bin/hostname"))
  157.             (substr #output 0 (- (strlen #output) 1))
  158.         ;else
  159.             (P_gethostnamevars)
  160.         )
  161.     )
  162. )
  163.  
  164. ; Guess where to install qmail.
  165. (procedure P_guessDestDir
  166.     (if (= #TCPstack "AmiTCP/IP")
  167.         (if (exists "AmiTCP:" (noreq))
  168.             "AmiTCP:qmail"
  169.             (tackon @default-dest "qmail")
  170.         )
  171.  
  172.     (if (= #TCPstack "Miami")
  173.         (if (exists "Miami:" (noreq))
  174.             "Miami:qmail"
  175.             (tackon @default-dest "qmail")
  176.         )
  177.  
  178.     (if (= #TCPstack "INET225")
  179.         (if (exists "Inet:" (noreq))
  180.             "Inet:qmail"
  181.             (tackon @default-dest "qmail")
  182.         )
  183.  
  184.     ; No TCP/IP stack.
  185.     (tackon @default-dest "qmail")
  186.  
  187.     )))
  188. )
  189.  
  190. ; Kort pause.
  191. (procedure P_delay _n
  192.     (set _c 0)
  193.     (while (< _c _n)
  194.         (set _c (+ _c 1))
  195.     )
  196. )
  197.  
  198. ; Sej intro ;-)
  199. (procedure P_coolIntro
  200.     (working "\n\n\n\n\n\n\n\n\n\n\n\n                              qmail                              ") (P_delay 50)
  201.     (working "\n\n\n\n\n\n\n\n\n\n\n                              qmail                              ") (P_delay 50)
  202.     (working "\n\n\n\n\n\n\n\n\n\n                              qmail                              ") (P_delay 50)
  203.     (working "\n\n\n\n\n\n\n\n\n                              qmail                              ") (P_delay 60)
  204.     (working "\n\n\n\n\n\n\n\n                              qmail                              ") (P_delay 60)
  205.     (working "\n\n\n\n\n\n\n                              qmail                              ") (P_delay 70)
  206.     (working "\n\n\n\n\n\n                              qmail                              ") (P_delay 80)
  207.     (working "\n\n\n\n\n                              qmail                              ") (P_delay 90)
  208.     (working "\n\n\n\n                              qmail                              ") (P_delay 110)
  209.     (working "\n\n\n                              qmail                              ") (P_delay 130)
  210.     (working "\n\n                              qmail                              ") (P_delay 160)
  211.     
  212.     (working "\n\nAmiga                         qmail                              ") (P_delay 20)
  213.     (working "\n\n Amiga                        qmail                              ") (P_delay 20)
  214.     (working "\n\n  Amiga                       qmail                              ") (P_delay 20)
  215.     (working "\n\n   Amiga                      qmail                              ") (P_delay 20)
  216.     (working "\n\n    Amiga                     qmail                              ") (P_delay 20)
  217.     (working "\n\n     Amiga                    qmail                              ") (P_delay 20)
  218.     (working "\n\n      Amiga                   qmail                              ") (P_delay 20)
  219.     (working "\n\n       Amiga                  qmail                              ") (P_delay 20)
  220.     (working "\n\n        Amiga                 qmail                              ") (P_delay 20)
  221.     (working "\n\n         Amiga                qmail                              ") (P_delay 20)
  222.     (working "\n\n          Amiga               qmail                              ") (P_delay 20)
  223.     (working "\n\n           Amiga              qmail                              ") (P_delay 20)
  224.     (working "\n\n            Amiga             qmail                              ") (P_delay 20)
  225.     (working "\n\n             Amiga            qmail                              ") (P_delay 20)
  226.     (working "\n\n              Amiga           qmail                              ") (P_delay 20)
  227.     (working "\n\n               Amiga          qmail                              ") (P_delay 20)
  228.     (working "\n\n                Amiga         qmail                              ") (P_delay 20)
  229.     (working "\n\n                 Amiga        qmail                              ") (P_delay 20)
  230.     (working "\n\n                  Amiga       qmail                              ") (P_delay 20)
  231.     (working "\n\n                   Amiga      qmail                              ") (P_delay 20)
  232.     (working "\n\n                    Amiga     qmail                              ") (P_delay 20)
  233.     (working "\n\n                     Amiga    qmail                              ") (P_delay 20)
  234.     (working "\n\n                      Amiga   qmail                              ") (P_delay 20)
  235.     (working "\n\n                       Amiga  qmail                              ") (P_delay 20)
  236.     (working "\n\n                        Amiga qmail                              ") (P_delay 20)
  237.     (working "\n\n                         Amigaqmail                              ") (P_delay 20)
  238.     (working "\n\n                          Amiga qmail                            ") (P_delay 40)
  239.     (working "\n\n                           Amiga  qmail                          ") (P_delay 60)
  240.     (working "\n\n                            Amiga  qmail                         ") (P_delay 90)
  241.     (working "\n\n                           Amiga  qmail                          ") (P_delay 120)
  242.     (working "\n\n                           Amiga qmail                           ") (P_delay 160)
  243.     (message "\n\n\n\nAmiga qmail\n\nversion 1.01")
  244. )
  245.     
  246. ; Ask user about in-place installation.
  247. (procedure P_askInPlace
  248. ;    (if (> @user-level 0)
  249.         (askbool
  250.             (prompt #askInPlace)
  251.             (help (cat #askInPlaceHelp @askbool-help))
  252.             (default 0)
  253.         )
  254.     ;else
  255. ;        0
  256. ;    )
  257. )
  258.  
  259. ; Prompt user for directory to install into.
  260. (procedure P_askDestDir
  261.     (if (> @user-level 0)
  262.         (askdir
  263.                (prompt #askDestDir)
  264.                (help (cat #askDestDirHelp @askdir-help))
  265.                (default @default-dest)
  266.                (newpath)
  267.                ;(assigns)
  268.         )
  269.     ;else
  270.         @default-dest
  271.     )
  272. )
  273.  
  274. ; Find the fully qualified name of the host.
  275. (procedure P_fqhostname _hostname
  276.     (if (= 0 (P_run (cat "bin/dnsfq " _hostname)))
  277.         (substr #output 0 (- (strlen #output) 1))
  278.     ;else
  279.         _hostname
  280.     )
  281. )
  282.  
  283. ; Return the "domain" part of a string (everything after the first '.').
  284. (procedure P_getdomain _hostname
  285.     (substr _hostname (+ (P_strchr _hostname ".") 1))
  286. )
  287.  
  288. ; Return an LF separated list of local IP numbers
  289. (procedure P_getlocalIPs
  290.     (if (= 0 (P_run "bin/ipmeprint"))
  291.         (substr #output 0 (- (strlen #output) 1))
  292.     ;else
  293.         ; FIXME Could try "dnsip hostname" also
  294.         "127.0.0.1"
  295.     )
  296. )
  297.  
  298. ; Convert a LF separated list of local IP numbers to a LF separated list
  299. ; of hostnames, and include the host name given.
  300. (procedure P_getlocals _localIPs _hostname
  301. (
  302.     (set _locals _hostname)
  303.     (set _end (P_strchr _localIPs "\n"))
  304.     (while (<> 0 _end)
  305.     (
  306.         (set _IP (substr _localIPs 0 _end))
  307.         (if (= 0 (P_run (cat "bin/dnsptr " _IP)))
  308.         (
  309.             (set #output (substr #output 0 (- (strlen #output) 1)))
  310.             (if (<> #output _hostname)
  311.                 (set _locals (cat _locals "\n" #output))
  312.             )
  313.         ))
  314.         (set _localIPs (substr _localIPs (+ _end 1)))
  315.         (set _end (P_strchr _localIPs "\n"))
  316.     ))
  317.     _locals
  318. ))
  319.  
  320. ; Convert a LF separated list of local IP numbers to a LF separated list
  321. ; of relayclients (for the control/relayclients file).
  322. (procedure P_getrelayclients _localIPs
  323. (
  324.     (set _end (P_strchr _localIPs "\n"))
  325.     (while (<> 0 _end)
  326.     (
  327.         (set _IP (substr _localIPs 0 _end))
  328.         (set _localIPs (substr _localIPs (+ _end 1)))
  329.         (set _relayclients (cat _relayclients _IP ":\n"))
  330.         (set _end (P_strchr _localIPs "\n"))
  331.     ))
  332.     _relayclients
  333. ))
  334.  
  335. ; Write control files
  336. (procedure P_writecontrols
  337. (
  338.     (set _controldir (tackon @default-dest "control"))
  339.     (makedir _controldir (infos))
  340.  
  341.     (textfile
  342.         (dest (tackon _controldir "me"))
  343.         (append #hostname) (append "\n")
  344.     )
  345.     (P_makeicon "controlfile" (tackon _controldir "me"))
  346.  
  347.     (textfile
  348.         (dest (tackon _controldir "defaultdomain"))
  349.         (append #defaultdomain) (append "\n")
  350.     )
  351.     (P_makeicon "controlfile" (tackon _controldir "defaultdomain"))
  352.  
  353.     (textfile
  354.         (dest (tackon _controldir "plusdomain"))
  355.         (append #plusdomain) (append "\n")
  356.     )
  357.     (P_makeicon "controlfile" (tackon _controldir "plusdomain"))
  358.  
  359.     (textfile
  360.         (dest (tackon _controldir "locals"))
  361.         (append #locals) (append "\n")
  362.     )
  363.     (P_makeicon "controlfile" (tackon _controldir "locals"))
  364.  
  365.     (textfile
  366.         (dest (tackon _controldir "rcpthosts"))
  367.         (include (tackon _controldir "locals"))
  368.     )
  369.     (P_makeicon "controlfile" (tackon _controldir "rcpthosts"))
  370.  
  371.     (if (<> #TCPstack "None")
  372.     (
  373.         (textfile
  374.             (dest (tackon _controldir "relayclients"))
  375.             (append #relayclients)
  376.         )
  377.         (P_makeicon "controlfile" (tackon _controldir "relayclients"))
  378.     ))
  379. ))
  380.  
  381. ; Create resolv.conf for DNS lookups.
  382. (procedure P_create_resolv_conf
  383. (
  384.     (makedir (tackon @default-dest "etc") (infos))
  385.     (set _resolv_conf (tackon @default-dest "etc/resolv.conf"))
  386.  
  387.     ; AmiTCP/IP and INET225 store this information in an ASCII file.
  388.     (if (OR (= #TCPstack "AmiTCP/IP") (= #TCPstack "INET225"))
  389.     (
  390.         (if (exists "INET:db/resolv.conf" (noreq))
  391.             (set _dns_conf "INET:db/resolv.conf")
  392.         ;else
  393.         (if (exists "AmiTCP:db/resolv.conf" (noreq))
  394.             (set _dns_conf "AmiTCP:db/resolv.conf")
  395.         ;else
  396.         (if (exists "AmiTCP:db/netdb-myhost" (noreq))
  397.             (set _dns_conf "AmiTCP:db/netdb-myhost")
  398.         ;else
  399.         (if (exists "AmiTCP:db/netdb" (noreq))
  400.             (set _dns_conf "AmiTCP:db/netdb")
  401.         ))))
  402.  
  403.         ; Create etc/resolv.conf
  404.         (if _dns_conf
  405.         (
  406.             (run (cat "Edit FROM \"" _dns_conf "\""
  407.                       " TO ENV:InstallScriptTemp1 WITH instutils/nameserver.edit"
  408.                       " OPT P2W10240")
  409.                  (safe)
  410.             )
  411.             (rexx (cat "instutils/domainsearch.rexx " _dns_conf
  412.                        " ENV:InstallScriptTemp2")
  413.                  (safe)
  414.             )
  415.             (textfile (dest _resolv_conf)
  416.                       (include "ENV:InstallScriptTemp1")
  417.                       (include "ENV:InstallScriptTemp2")
  418.                       (append "\n")
  419.             )
  420.             (delete "ENV:InstallScriptTemp1" (safe))
  421.             (delete "ENV:InstallScriptTemp2" (safe))
  422.             (P_makeicon "controlfile" _resolv_conf)
  423.         ))
  424.     )
  425.     ;else
  426.     (if (= #TCPstack "Miami")
  427.     (
  428.         (P_run "SYS:RexxC/RX \"options RESULTS; address MIAMI.1 GETSETTINGSNAME; say result\"")
  429.         (set _MiamiConfig (substr #output 0 (- (strlen #output) 1)))
  430.         (run (cat "instutils/MiamiDNSFind <\"" _MiamiConfig
  431.                   "\" >\"" _resolv_conf "\""))
  432.         (P_makeicon "controlfile" _resolv_conf)
  433.     )))
  434. ))
  435.  
  436. ; Create a drawer with 'conf_split' subdrawers in it
  437. (procedure P_makesplitdir _dir
  438. (
  439.     (makedir _dir)
  440.     (set _i 0)
  441.     (while (< _i 23)
  442.     (
  443.         (makedir (tackon _dir (cat _i)))
  444.         (set _i (+ _i 1))
  445.     ))
  446. ))
  447.  
  448. ; Create the various drawers used by the qmail system.
  449. (procedure P_createQmailDirs
  450. (
  451.     (set _queue (tackon @default-dest "queue"))
  452.     (set _alias (tackon @default-dest "alias"))
  453.     (makedir _queue)
  454.     (P_makesplitdir (tackon _queue "mess"))
  455.     (P_makesplitdir (tackon _queue "info"))
  456.     (P_makesplitdir (tackon _queue "local"))
  457.     (P_makesplitdir (tackon _queue "remote"))
  458.     (makedir (tackon _queue "pid"))
  459.     (makedir (tackon _queue "intd"))
  460.     (makedir (tackon _queue "todo"))
  461.     (makedir (tackon _queue "bounce"))
  462.     (makedir (tackon _queue "lock"))
  463.     (textfile (dest (tackon _queue "lock/sendmutex")))
  464.     (makedir _alias (infos))
  465.     (textfile (dest (tackon _alias ".qmail-root")))
  466.     (textfile (dest (tackon _alias ".qmail-postmaster")))
  467.     (textfile (dest (tackon _alias ".qmail-mailer-daemon")))
  468.     (P_makeicon "controlfile" (tackon _alias ".qmail-root"))
  469.     (P_makeicon "controlfile" (tackon _alias ".qmail-postmaster"))
  470.     (P_makeicon "controlfile" (tackon _alias ".qmail-mailer-daemon"))
  471.     (set @execute-dir _alias)
  472.     (set _currentdir (expandpath ""))
  473.     (run (cat (tackon _currentdir "utils/minichown")
  474.               " alias .qmail-root .qmail-postmaster .qmail-mailer-daemon"))
  475.     (run (cat (tackon _currentdir "utils/minichgrp")
  476.               " nofiles .qmail-root .qmail-postmaster .qmail-mailer-daemon"))
  477.     (set @execute-dir "")
  478.     (makedir (tackon @default-dest "users") (infos))
  479. ))
  480.  
  481. ; Update the database of the TCP/IP stack.
  482. (procedure P_updateDatabase
  483. (
  484.     ; Convert dirname to ixemul notation.
  485.     (set _i (P_strchr @default-dest ":"))
  486.     (set _qmail (cat "/" (substr @default-dest 0 _i) "/" (substr @default-dest (+ _i 1))))
  487.  
  488.     ; inetd conf
  489.     (if (= #TCPstack "AmiTCP/IP")
  490.         (textfile (dest "AmiTCP:db/inetd.conf")
  491.                   (include "AmiTCP:db/inetd.conf")
  492.                   (append (cat "smtp    stream    tcp    nowait    qmaild    "
  493.                                (tackon @default-dest "bin/tcp-env") "    tcp-env    "
  494.                                (tackon @default-dest "bin/qmail-smtpd") "\n")
  495.                   )
  496.         )
  497.     ;else
  498.     (if (= #TCPstack "INET225")
  499.         (textfile (dest "INET:db/inetd.conf")
  500.                   (include "INET:db/inetd.conf")
  501.                   (append (cat "smtp    stream    tcp    nowait    qmaild    "
  502.                                (tackon @default-dest "bin/tcp-env") "    tcp-env    "
  503.                                (tackon @default-dest "bin/qmail-smtpd") "\n")
  504.                   )
  505.         )
  506.     ;else
  507.     (if (= #TCPstack "Miami")
  508.     (
  509.         (textfile (dest "ENVARC:MiamiChangeDB")
  510.                   (append (cat "ADD inetd smtp stream tcp nowait qmaild "
  511.                                (tackon @default-dest "bin/tcp-env") " tcp-env "
  512.                                (tackon @default-dest "bin/qmail-smtpd") "\n")
  513.                   )
  514.         )
  515.         (run "SYS:RexxC/RX \"address MIAMI.1 CHANGEDB\"")
  516.     )
  517.     )))
  518.  
  519.     ; Try to get inetd.conf reloaded if not done automatically
  520.     (run "Break `Status COMMAND inetd` F")
  521.  
  522.     ; User/group databases
  523.     (if (= #TCPstack "Miami")
  524.     (
  525.         (set _users  "T:qmail users")
  526.         (set _groups "T:qmail groups")
  527.     )
  528.     ;else
  529.     (if (= #TCPstack "AmiTCP/IP")
  530.     (
  531.         (set _users  "AmiTCP:db/passwd")
  532.         (set _groups "AmiTCP:db/group")
  533.     )
  534.     ;else
  535.     (if (= #TCPstack "INET225")
  536.     (
  537.         (set _users  "INET:db/passwd")
  538.         (set _groups "INET:db/group")
  539.     )
  540.     ;else
  541.     (
  542.         (if (exists "ETC:passwd" (noreq))
  543.             (set _users "ETC:passwd")
  544.             ;else
  545.             (
  546.                 (set _users (tackon @default-dest "etc/passwd"))
  547.                 (makedir (tackon @default-dest "etc") (infos))
  548.                 (P_makeicon "controlfile" _users)
  549.             )
  550.         )
  551.         (if (exists "ETC:group" (noreq))
  552.             (set _groups "ETC:group")
  553.             ;else
  554.             (
  555.                 (set _groups (tackon @default-dest "etc/group"))
  556.                 (makedir (tackon @default-dest "etc") (infos))
  557.                 (P_makeicon "controlfile" _groups)
  558.             )
  559.         )
  560.     ))))
  561.  
  562.     (textfile (dest _users)
  563.         (include _users)
  564.         (append (cat "alias|*|7790|2108||" (tackon @default-dest "alias") "|noshell\n"))
  565.         (append (cat "qmaild|*|7791|2108||" _qmail "|noshell\n"))
  566.         (append (cat "qmaill|*|7792|2108||" _qmail "|noshell\n"))
  567.         (append (cat "qmailp|*|7793|2108||" _qmail "|noshell\n"))
  568.         (append (cat "qmailq|*|7794|2107||" _qmail "|noshell\n"))
  569.         (append (cat "qmailr|*|7795|2107||" _qmail "|noshell\n"))
  570.         (append (cat "qmails|*|7796|2107||" _qmail "|noshell\n"))
  571.     )
  572.     (textfile (dest _groups)
  573.         (include _groups)
  574.         (append "qmail|*|2107|\n")
  575.         (append "nofiles|*|2108|\n")
  576.     )
  577.  
  578.     (if (= #TCPstack "Miami")
  579.     (
  580.         (set _msg (#msgMiamiDatabase _users _groups))
  581.         (message _msg (all))
  582.         (delete _users)
  583.         (delete _groups)
  584.     ))
  585. ))
  586.  
  587. ; Copy the files
  588. (procedure P_copyFiles
  589. (
  590.     (copyfiles
  591.         (source "bin")
  592.         (dest (tackon @default-dest "bin"))
  593.         (all)
  594.         (infos)
  595.     )
  596.     (copyfiles
  597.         (source "utils")
  598.         (dest (tackon @default-dest "utils"))
  599.         (all)
  600.         (infos)
  601.     )
  602.     (copyfiles
  603.         (source "man")
  604.         (dest (tackon @default-dest "man"))
  605.         (all)
  606.         (infos)
  607.     )
  608.     (copyfiles
  609.         (source "docs")
  610.         (dest (tackon @default-dest "docs"))
  611.         (all)
  612.         (infos)
  613.     )
  614. ))
  615.  
  616. ; Perform various fixes to the installed files.
  617. (procedure P_fixup
  618. (
  619.     ; Fix the owner and attributes of bin/qmail-queue
  620.     (set _currentdir (expandpath ""))
  621.     (set @execute-dir (tackon @default-dest "bin"))
  622.     (run (cat (tackon _currentdir "utils/minichown") " qmailq qmail-queue"))
  623.     (run (cat (tackon _currentdir "utils/minichmod") " 82FAA qmail-queue"))
  624.     (set @execute-dir "")
  625. ))
  626.  
  627. ; Ask the user if qmail should be started now.
  628. (procedure P_askStartNow
  629.     (askbool
  630.         (prompt #askStartNow)
  631.         (help "")
  632.         (default 1)
  633.     )
  634. )
  635.  
  636. ; Create start/stop scripts and add a line to S:User-Startup
  637. (procedure P_createStartup
  638. (
  639.     ; Convert dirname to ixemul notation.
  640.     (set _ix_bin (tackon @default-dest "bin"))
  641.     (set _i (P_strchr _ix_bin ":"))
  642.     (set _ix_bin (cat "/" (substr _ix_bin 0 _i) "/" (substr _ix_bin (+ _i 1))))
  643.  
  644.     (textfile (dest (tackon @default-dest "Start qmail"))
  645.         (append (cat "CD \"" @default-dest "\"\n"))
  646.         (append "Path ADD bin utils\n")
  647.         (append (cat "Set PATH \"" _ix_bin ":${PATH}\"\n"))
  648.         (append "Run <NIL: >NIL: bin/qmail-start Mailbox bin/splogger qmail\n")
  649.     )
  650.     (P_makeicon "scriptfile" (tackon @default-dest "Start qmail"))
  651.  
  652.     (textfile (dest (tackon @default-dest "Stop qmail"))
  653.         (append "Break <NIL: >NIL: `Status COMMAND qmail-send` C\n")
  654.         (append "Break <NIL: >NIL: `Status COMMAND qmail-clean` C\n")
  655.         (append "Break <NIL: >NIL: `Status COMMAND qmail-lspawn` C\n")
  656.         (append "Break <NIL: >NIL: `Status COMMAND qmail-rspawn` C\n")
  657.         (append "Break <NIL: >NIL: `Status COMMAND splogger` C\n")
  658.     )
  659.     (P_makeicon "scriptfile" (tackon @default-dest "Stop qmail"))
  660.         
  661.     (textfile (dest (tackon @default-dest "Flush queue"))
  662.         (append "Break <NIL: >NIL: `Status COMMAND qmail-send` E\n")
  663.     )
  664.     (P_makeicon "scriptfile" (tackon @default-dest "Flush queue"))
  665.         
  666.     (textfile (dest (tackon @default-dest "Reload controlfiles"))
  667.         (append "Break <NIL: >NIL: `Status COMMAND qmail-send` F\n")
  668.     )
  669.     (P_makeicon "scriptfile" (tackon @default-dest "Reload controlfiles"))
  670.         
  671.     (startup @app-name
  672.         (prompt #askUserStartup)
  673.         (help @startup-help)
  674.         (confirm)
  675.         (command (cat "Assign ADD ETC: \"" (tackon @default-dest "etc")
  676.             "\"\n"))
  677.         (command (cat "Run <NIL: >NIL: Execute \""
  678.             (tackon @default-dest "Start qmail") "\" <NIL: >NIL:\n"))
  679.     )
  680. ))
  681.  
  682. ;----- Main programme. -----
  683.  
  684. (P_coolIntro)
  685. (welcome)
  686. (P_doLocaleStrings)
  687.  
  688. (set #TCPstack (P_guessTCPstack))
  689. (set #inplace (P_askInPlace))
  690. (set @default-dest (P_guessDestDir))
  691. (if #inplace
  692.     (set @default-dest (expandpath ""))
  693.     ;else
  694.     (set @default-dest (P_askDestDir))
  695. )
  696. (if (NOT (exists @default-dest))
  697.     (makedir @default-dest (infos))
  698. )
  699. (set @default-dest (expandpath @default-dest))
  700.  
  701. (working #msgCreatingUsers)
  702. (P_updateDatabase)
  703.  
  704. (P_createStartup)
  705.  
  706. (set #hostname (P_gethostname))
  707.  
  708. (if (<> #TCPstack "None")
  709. (
  710.     (working #msgDNSsearch)
  711.     (P_create_resolv_conf)
  712.     (working #msgDNSlookup)
  713.     (run (cat "Assign ADD ETC: \"" (tackon @default-dest "etc") "\""))
  714.     (set #hostname (P_fqhostname #hostname))
  715.     (set #localIPs (P_getlocalIPs))
  716.     (set #locals (P_getlocals #localIPs #hostname))
  717.     (set #relayclients (P_getrelayclients #localIPs))
  718.     (run (cat "Assign REMOVE ETC: \"" (tackon @default-dest "etc") "\""))
  719. )
  720. ;else
  721.     (set #locals #hostname)
  722. )
  723.  
  724. (set #defaultdomain (P_getdomain #hostname))
  725. (set #plusdomain (P_getdomain #defaultdomain))
  726.  
  727. (working #msgWritingControls)
  728. (P_writecontrols)
  729.  
  730. (working #msgCreatingDirs)
  731. (P_createQmailDirs)
  732.  
  733. (if (NOT #inplace)
  734.     (P_copyFiles)
  735. )
  736.  
  737. (P_fixup)
  738.  
  739. (run (cat "Assign ADD ETC: \"" (tackon @default-dest "etc")    "\"\n"))
  740.  
  741. (if (P_askStartNow)
  742.  
  743.     (execute (cat "\"" (tackon @default-dest "Start qmail") "\""))
  744. )
  745.